<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title></title>
</head>
<body>
<!-- Modal -->
<div class="modal fade" id="orderInfo" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header" style="height: 50px;">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">下单</h4>
            </div>
            <div class="modal-body">
                <form action="#" style="margin:0 auto;width: 80%;">
                    <div class="form-group">
                        <label for="name">用户名</label>
                        <input type="text" disabled="disabled" name="userName" value="唐僧肉" id="name" class="form-control" placeholder="">
                    </div>
                    <div class="form-group form-group-options" style="width: 35%;">
                        <label for="1inp">数量</label>
                        <div id="1" class="input-group input-group-option quantity-wrapper">
                                <span class="input-group-addon input-group-addon-remove quantity-remove btn">
                                    <span id="removeBtn" class="glyphicon glyphicon-minus"></span>
                                </span>
                            <input id="1inp" disabled="disabled" type="number" value="1" name="number" class="form-control quantity-count"
                                   placeholder="1">
                            <span class="input-group-addon input-group-addon-remove quantity-add btn">
                                    <span id="addBtn" class="glyphicon glyphicon-plus"></span>
                                </span>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="address">交易地址</label>
                        <input type="text" name="transactionAddress" id="address" class="form-control" placeholder="">
                    </div>
                    <div class="form-group">
                        <label for="phone">联系电话</label>
                        <input type="text" name="phone" id="phone" class="form-control" placeholder="">
                    </div>
                    <div class="form-group">
                        <label for="note">备注</label><span class="pull-right">/50</span><span class="pull-right" id="textarea_str_num">50</span>
                        <input id="note" rows="1" onkeydown="limit_number();" maxlength="50" name="note" id="note"
                               class="form-control" placeholder=""/>
                    </div>
                </form>
            </div>
            <div class="modal-footer" style="height: 70px;">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary">确认</button>
            </div>
        </div>
    </div>
</div>
<script>
    $(function () {
        $("#addBtn").on("click",function () {
            let num = parseInt($("#1inp").val()) + 1;
            if(num <= 10){
                $("#1inp").val(num);
            }
        });
        $("#removeBtn").on("click",function () {
            let num = parseInt($("#1inp").val()) - 1;
            if(num > 0){
                $("#1inp").val(num);
            }
        });
    });
    //限制文本域中的字符数
    function limit_number(event) {
        $('#textarea_str_num').text(50 - ($('#note').val().length));
    }
</script>
</body>
</html>
